-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add push flag to support pushing to registry directly #294
feat: add push flag to support pushing to registry directly #294
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #294 +/- ##
==========================================
+ Coverage 33.02% 33.49% +0.46%
==========================================
Files 17 17
Lines 1626 1663 +37
==========================================
+ Hits 537 557 +20
- Misses 1060 1072 +12
- Partials 29 34 +5
☔ View full report in Codecov by Sentry. |
I am wondering if we should align with buildx CLI here. Ideally, we don't want to break existing users so what I was thinking was to use
@jeremyrickard @cpuguy83 wdyt? |
I like the I also think that adding a --push flag would be useful, especially if it didn't require docker locally. Not the same scenario, but the experience with |
cool, happy to go with what you folks suggested. Although, I am not sure about this bit:
This might still be what the user wants, partially due to how popular dockerhub is: Even this bit, might be specific to how registries should manage it. Many registries would just accept it and tag it as
|
c3f71ed
to
86b794b
Compare
I've pushed a commit to get most of what you folks suggested. Added couple test cases that shows we'll be backwards-compatible and a new case for specifying a different registry. I've tried to stay unopinionated about destination registry conventions as copa will throw an error during push if buildkit fails to push anyway. Happy to take your suggestions tho |
I think setting up the mock buildkit API in unit tests failed, is it acting flaky? |
this is being consistent with |
66fcf39
to
46f56f1
Compare
cool, I've added the registry check @sozercan |
cb525c9
to
7e736d6
Compare
@sozercan @jeremyrickard don't mean to badger, is there anything else you'd like me to change on this PR? |
@RealHarshThakur sorry for the delay - @sozercan has been on vacation for the past couple days. I'll see if I can get you a review asap :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the delay! Please see comments
pkg/buildkit/buildkit.go
Outdated
@@ -232,3 +232,47 @@ func SolveToDocker(ctx context.Context, c *client.Client, st *llb.State, configD | |||
}) | |||
return eg.Wait() | |||
} | |||
|
|||
func SolveToRegistry(ctx context.Context, c *client.Client, st *llb.State, configData []byte, tag string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like duplicating the existing code, can we refactor to share the logic?
pkg/patch/patch.go
Outdated
return nil, err | ||
} | ||
if ref.IsNameOnly(imageName) { | ||
log.Warnf("Image name has no tag or digest, using latest as tag") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Warnf("Image name has no tag or digest, using latest as tag") | |
log.Warn("image name has no tag or digest, using latest as tag") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although not sure if we get to this point, since i believe it'll fast fail before this
pkg/patch/patch_test.go
Outdated
{ | ||
name: "tag passed but without registry or repo", | ||
image: "docker.io/library/nginx:1.21.3", | ||
patchedTag: "my.registry/nginx:1.21.3-patched", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be valid (something like myregistry.azurecr.io/nginx:1.21.3-patched
)
pkg/patch/patch.go
Outdated
if slashCount > 0 { | ||
if slashCount < 2 { | ||
err := fmt.Errorf("invalid tag %s, must be in the form <registry>/<image>:<tag>", patchedTag) | ||
log.Error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is duplicate, since return is logged already?
ping @RealHarshThakur. we are getting close to cutting v0.5.0 release if you want this to be included |
I'll try but most likely, I'll be able to pick it up by end of the month |
Signed-off-by: Harsh Thakur <[email protected]>
Signed-off-by: Harsh Thakur <[email protected]>
Signed-off-by: Harsh Thakur <[email protected]>
Signed-off-by: Harsh Thakur <[email protected]>
d689d89
to
82060be
Compare
@sozercan sorry for the delay, I've made the changes you've requested. |
@RealHarshThakur thanks! can you please rebase when you get a chance? looks there are a few conflicts now. |
Closing due to inactivity. Please feel free to re-open if there's ongoing work. Thanks! |
This PR enables direct push to registry from buildkit:
One side-effect of this would be that copa wouldn't rely on Docker anymore if there is a remote buildkit setup as I mentioned here. #285 (comment)
Closes #293